using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace PasteSourceAsHtml
{
    [WriterPluginAttribute
   ("6317F6F1-D284-45D3-9634-99EEAD02D16C",
    "Paste as Html",
    ImagePath = "Images.Paste.png",
    PublisherUrl = "http://blogs.sqlxml.org/bryantlikes",
    Description = "Paste html from your clipboard into the post")]


    [InsertableContentSourceAttribute("Clipboard Html")]
    public class Plugin : ContentSource
    {
        public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
        {
            DialogResult result = DialogResult.OK;
            if (Clipboard.ContainsText() == true)
            {
                newContent = Clipboard.GetText();
            }
            else
            {
                result = MessageBox.Show(dialogOwner, "Copy your HTML to the clipboard.", "Paste as Html", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK && Clipboard.ContainsText() == true)
                {
                    newContent = Clipboard.GetText();
                }
            }

            return result;
        }
    }
}
